var path = require('path');
var htmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
    /* entry:{
        main:'./src/script/main.js',
        a:['./src/script/a.js'],
        b:['./src/script/b.js'],
        c:['./src/script/c.js']
    },
    output:{
        path: path.resolve(__dirname, 'dist'),
        filename:'js/[name]-[chunkhash].js',
        publicPath:'http://yoosun.cn' /!*需要上线的时候添加地址*!/
    },
    plugins:[
        new htmlWebpackPlugin({
            filename:'a.html',
            template:'index.html',
            inject:'body',   /!*包含在body标签内*!/
            title:'webpacka is good',
            /!*chunks:['main','a']*!/  /!*引用包括这些chunks的文件*!/
            excludeChunks:['b','c']  /!*引用除了这些chunks的文件*!/
           /!* minify:{
                removeComments:true, /!*删除注释*!/
                collapseWhitespace:true, /!*删除空格*!/
            }*!/
        }),
        new htmlWebpackPlugin({
            filename:'b.html',
            template:'index.html',
            inject:false,
            title:'webpackb is good',
            excludeChunks:['a','c']
        }),
        new htmlWebpackPlugin({
            filename:'c.html',
            template:'index.html',
            inject:false,
            title:'webpackc is good',
            excludeChunks:['b','a']
        })
    ] */
    context : __dirname,
    entry:'./src/app.js',
    output:{
        path:path.resolve(__dirname, 'dist'),
        filename:'ja/[name].bundle.js'
    },
    module:{
        loaders:[
            {
                test:/\.js$/,
                loader:'babel-loader',
                exclude:path.resolve(__dirname, 'node_modules'),   /*优化打包速度*/
                include:path.resolve(__dirname, 'src')
               /* options:{
                    'presets':['latest']   /!*也可以写在json文件中,不用每次都配置*!/
                }*/
            },
            {
                test:/\.css$/,
                loader:'style-loader!css-loader?importLoaders=1!postcss-loader'
            },
            {
                test:/\.less$/,
                loader:'style-loader!css-loader!postcss-loader!less-loader'
            },
            {
                test:/\.html$/,
                loader:'html-loader'
            },
            {
                test:/\.tpl$/,
                loader:'ejs-loader'
            },
           /* {
                test:/\.(png|jpg|gif|svg)$/i,
                loader:'file-loader',
                query:{
                    name:'assets/[name]-[hash:5].[ext]'
                }
            },*/
           /* {
                test:/\.(png|jpg|gif|svg)$/i,
                loader:'url-loader',
                query:{
                    limit:20000,
                    name:'assets/[name]-[hash:5].[ext]'
                }
            },*/
            {
                test:/\.(png|jpg|gif|svg)$/i,
                loaders:[
                    'url-loader?limit=1000&name=assets/[name]-[hash:5].[ext]',
                    'img-loader'
               ]
            }
            /*{
                test:/\.scss$/,
                loader:'style-loader!css-loader!postcss-loader!sass-loader'
            }*/
        ],
    },
    plugins:[
        new htmlWebpackPlugin({
            filename:'index.html',
            template:'index.html',
            inject:'body'
        })
    ]
};
